package com.leet.meituan;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class FieldConference {

    private static int n,k;
    private static int[] level;
    private static boolean[] used;
    private static int mod = 1000000007;
    private static List<List<Integer>> e;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        e = new ArrayList<>();
        // n+1个list
        for(int i = 0;i <= n;i++){
            e.add(new ArrayList<>());
        }
        level = new int[n+1];
        used = new boolean[n+1];
        for(int i = 1;i < n;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            e.get(x).add(y);
            e.get(y).add(x);
        }
        for(int i = 1; i <= n ;i++){
            level[i] = sc.nextInt();
        }
        long ans = 0;
        for(int i = 1;i <= n; i++){
            Arrays.fill(used,false);
            ans = (ans + dfs(i,i)) % mod;
        }
        System.out.println(ans);
    }
    private static long dfs(int u,int s){
        used[u] = true;
        long ans = 1;
        for(int v:e.get(u)){
            if(used[v]) continue;
            if(level[v] > level[s] && level[v] - level[s] <= k || level[v] == level[s] && v > s){
                ans = ans*(1+dfs(v,s))%mod;
            }
        }
        return ans;
    }
}
